#include "widget.h"
#include "ui_widget.h"
#include <QSerialPortInfo>
#include <QMessageBox>
#include <QDesktopServices>
#include <QUrl>
#include <about.h>
#include <QThread>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    //设置窗口标题
    this->setWindowTitle("水控工装测试");

    //创建对象
    serialPort = new QSerialPort(this);

    //手动关联信号与槽函数
    connect(serialPort,SIGNAL(readyRead()),this,SLOT(serialPortReadyRead_Slot()));

    //增加串口搜索
    QStringList serialList;
    foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) {
        serialList << info.portName();
    }
    ui->serialComb->addItems(serialList);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::serialPortReadyRead_Slot()//
{ 
    uchar *Hexbuf;//只是一个指针
    QByteArray buf;
    buf = serialPort->readAll();
    if(!buf.isEmpty())
    {
        Hexbuf = reinterpret_cast<unsigned char*>(buf.data());
        //接收数据区，处理并显示出来
        dispTestResult(Hexbuf);
    }
    buf.clear();    //清空缓存区
}


void Widget::on_openBt_clicked()
{
    QSerialPort::BaudRate baudRate;
    QSerialPort::Parity parity;
    QSerialPort::DataBits dataBits;
    QSerialPort::StopBits stopBits;

    if(ui->baudComb->currentText() == "9600"){
        baudRate = QSerialPort::Baud9600;
    }else {
        baudRate = QSerialPort::Baud115200;
    }

    if(ui->ParityComb->currentText() == "None"){
        parity = QSerialPort::NoParity;
    }else if (ui->ParityComb->currentText() == "奇校验") {
        parity = QSerialPort::EvenParity;
    }
    else {
            parity = QSerialPort::OddParity;
    }

    if(ui->dataComb->currentText() == "5"){
        dataBits = QSerialPort::Data5;
    }else if (ui->dataComb->currentText() == "6") {
        dataBits = QSerialPort::Data6;
    }else if (ui->dataComb->currentText() == "7") {
        dataBits = QSerialPort::Data7;
    }else {
        dataBits = QSerialPort::Data8;
    }

    if(ui->stopComb->currentText() == "1"){
        stopBits = QSerialPort::OneStop;
    }else if (ui->stopComb->currentText() == "1.5") {
        stopBits = QSerialPort::OneAndHalfStop;
    }else {
        stopBits = QSerialPort::TwoStop;
    }

    //设置端口参数
    serialPort->setPortName(ui->serialComb->currentText());
    serialPort->setBaudRate(baudRate);
    serialPort->setParity(parity);
    serialPort->setDataBits(dataBits);
    serialPort->setStopBits(stopBits);

    //打开串口
    sleep(100);
    if(opBtSta == 0){
        if(serialPort->open(QIODevice::ReadWrite) == true){
            opBtSta = 1;
            ui->openBt->setText("关闭");
            ui->infoDisp->setStyleSheet("border-image: url(:/pic/SerialOpen.png);");
            //设置控件不可点击
            setCmbDisb(true);
        }else {
            sleep(200);
            QMessageBox::critical(this,"错误","打开失败\n\n请检查串口是否被占用！");
            serialPort->clear();
            serialPort->close();//打开错误时关闭串口
            opBtSta = 0;
            setCmbDisb(false);
        }
    }else {
    //关闭
        serialPort->clear();
        serialPort->close();
        opBtSta = 0;
        ui->openBt->setText("打开");
        ui->infoDisp->setStyleSheet("border-image: url(:/pic/SerialClose.png);");
        setCmbDisb(false);
}


}


void Widget::on_cleanResultBt_clicked()
{
    ui->testSendEdit->clear();
    cleanResult();
}

void Widget::on_begainTestBt_clicked()
{
    QByteArray sendBuf;
    char *buf;
    sendBuf.resize(17);
    sendBuf[0] = 0x7F;
    sendBuf[1] = 0x7F;
    sendBuf[2] = 0x0A;
    sendBuf[3] = 0x23;
    sendBuf[4] = 0x04;  //板标识4：G401  7：H711
    //sendBuf[5] = 0x05;//目标版ID
    sendBuf[6] = 0x00;
    sendBuf[7] = 0x01;
    sendBuf[8] = 0x02;
    sendBuf[9] = 0x03;
    sendBuf[10] = 0x04;
    sendBuf[11] = 0x05;
    sendBuf[12] = 0x06;
    sendBuf[13] = 0x07;
    //sendBuf[14] = 0x2A;//和校验
    sendBuf[15] = 0x0D;
    sendBuf[16] = 0x0A;
    //判断端口是否打开
    if(opBtSta == 1){
        cleanResult();
        for (int i = 0;i < 6;i++) {
            sendBuf[5] = i+1;
            buf = sendBuf.data();
            sendBuf[14] = get_checksum(buf,14);
            serialPort->write(sendBuf);
            sleep(200);
        }
    }else {
        QMessageBox::critical(this,"错误","请先打开串口");
    }

}


quint16 Widget::crc16ForModbus(const QByteArray &data)
{
static const quint16 crc16Table[] =
{
    0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
    0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
    0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
    0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
    0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
    0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
    0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
    0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
    0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
    0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
    0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
    0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
    0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
    0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
    0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
    0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
    0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
    0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
    0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
    0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
    0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
    0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
    0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
    0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
    0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
    0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
    0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
    0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
    0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
    0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
    0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
    0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
    };
quint8 buf;
quint16 crc16 = 0xFFFF;

for (auto i = 0; i < data.size(); ++i)
{
    buf = data.at(i) ^ crc16;
    crc16 >>= 8;
    crc16 ^= crc16Table[buf];
}
return crc16;
}


void Widget::on_sofareUpdateBt_clicked()
{
    QDesktopServices::openUrl(QUrl(QString("https://github.com/luzeyang/PowerCtrlTools")));
}

void Widget::on_aboutBt_clicked()
{
    about *abt = new about;
    abt->show();
}

void Widget::on_keyModifyBt_clicked()
{
    QMessageBox::information(this,"提示","请等待后续添加！");
}

void Widget::on_shuikongUpdateBt_clicked()
{
    QMessageBox::information(this,"提示","请等待后续添加！");
}

//发送数据到串口
int Widget::writeData(char *data, int size)
{
    int len = 0;
    forever
    {
        int n = serialPort->write(&data[len], size - len);
        if (n == -1)
        {
            return -1;
        }
        else
        {
            len += n;
            if (size == len)
                break;
        }
    }
    return len;
}

//接收串口发来的数
int Widget::readData(char *buffer, int count, int timeout)
{
    int len = 0;
    forever
    {
        int n = serialPort->read(&buffer[len], count - len);
        if (n == -1)
        {
            return -1;
        }
        else if (n == 0 && !serialPort->waitForReadyRead(timeout))
        {
            return -2;
        }
        else
        {
            len += n;
            if (count == len)
                break;
        }
    }
    return len;
}

//字符串转16进制
QByteArray Widget::QString2Hex(QString str)
{
    QByteArray senddata;
    int hexdata,lowhexdata;
    int hexdatalen = 0;
    int len = str.length();

    senddata.resize(len/2);
    char lstr,hstr;

    for(int i=0; i<len; )
    {
        hstr=str[i].toLatin1();
        if(hstr == ' ')
        {
            i++;
            continue;
        }
        i++;
        if(i >= len)
            break;
        lstr = str[i].toLatin1();
        hexdata = ConvertHexChar(hstr);
        lowhexdata = ConvertHexChar(lstr);
        if((hexdata == 16) || (lowhexdata == 16))
            break;
        else
            hexdata = hexdata*16+lowhexdata;
        i++;
        senddata[hexdatalen] = (char)hexdata;
        hexdatalen++;
    }
    senddata.resize(hexdatalen);
    return senddata;
}
//字符转16进制
char Widget::ConvertHexChar(char ch)
{
    if((ch >= '0') && (ch <= '9'))
        return ch-0x30;
    else if((ch >= 'A') && (ch <= 'F'))
        return ch-'A'+10;
    else if((ch >= 'a') && (ch <= 'f'))
        return ch-'a'+10;
    else return (-1);
}

//延时函数
void Widget::sleep( int msec)
{
    QTime dieTime = QTime::currentTime().addMSecs(msec);
    while( QTime::currentTime() < dieTime )
    QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}

uint8_t Widget::get_checksum(char* dat, uint16_t len)
{
    uint8_t  sum = 0;
    uint16_t i;

    for(i=0;i<len;i++)
    {
        sum += dat[i];
    }
    return sum;
}
 void Widget::setCmbDisb(bool mod)
 {
     if(mod == true){
         ui->serialComb->setDisabled(true);
         ui->baudComb->setDisabled(true);
         ui->ParityComb->setDisabled(true);
         ui->dataComb->setDisabled(true);
         ui->stopComb->setDisabled(true);
     }else {
         ui->serialComb->setEnabled(true);
         ui->baudComb->setEnabled(true);
         ui->ParityComb->setEnabled(true);
         ui->dataComb->setEnabled(true);
         ui->stopComb->setEnabled(true);

    }

 }

 void Widget::dispTestResult(uchar *data)
 {
     //显示处理函数
     if(data[3] == 0xE9){
        //返回信息
         dispTips(data);
     }else if (data[3] == 0xEA) {
         //返回测试信息
         dispResult(data);
    }
}


 //添加线程类代码
 MyThread::MyThread(Widget * parent, QSerialPort *port)
 {
     this->parent = parent;//传入父对象，以便给它发信号
     this->port = port;//传入串口对象，以便在线程中使用
 }
 //CRC校验码计算
 unsigned short CRC16(unsigned char *pBuf,unsigned short len)
 {
     unsigned short uCRC=0xFFFF;
     int i,j;
     for(i=0;i<len;i++)
     {
         uCRC^=(*(pBuf+i));
         for(j=0;j<8;j++)
         {
             if((uCRC&0x0001)==0x0001)
             {
                 uCRC=(uCRC>>1);
                 uCRC^=0xA001;
             }
             else
                 uCRC=(uCRC>>1);
         }
     }
     return uCRC;
 }

 void MyThread::run()
 {
     bool bRet = false;
     unsigned char buf[6];
     //关联信号与槽，用于给父对象信号，告知通讯结果
     QObject::connect(this, SIGNAL(sendResult(int, QString)),
                         parent, SLOT(result(int, QString)));

     //与43个RS485设备通讯，检查设备是否有回应
     for(unsigned char addr = 1; addr <= 43 ; ++addr)
     {
         buf[0] = addr;
         buf[1] = 0x03;
         buf[2] = 0xA0;
         buf[3] = 0x06;
         unsigned short crc = CRC16(buf, 4);
         buf[4] = static_cast<unsigned char>(crc);
         buf[5] = static_cast<unsigned char>(crc >> 8);

         port->write(reinterpret_cast<const char *>(buf), 6);//发送数据
         port->flush();//让数据立刻从串口发送出去,不要在缓冲区里墨迹
         msleep(200);//等待200ms
         //检查串口接收到了多少数据
         int num = static_cast<int>(port->bytesAvailable());
         if(num != 6)
         {
             QString str = QString().sprintf("addr=%02d，设备没有响应, 返回数据量为%d",
                                             addr, static_cast<int>(num));
             emit sendResult(0, str);
         }else
         {
             // 接收到了6个字节，表时RS485设备有响应
             QByteArray array = port->readAll();
             QString str = QString().sprintf("addr=%02d, 发现设备，返回数据量为%d",
                                             addr, static_cast<int>(num));
             emit sendResult(0, str);
         }
         msleep(800);
     }
 }


void Widget::on_saveDataBt_clicked()
{
    QString textFile = QFileDialog::getSaveFileName(this,tr("Save txt"),"",tr("text (*.txt)")); //选择路径</font><br />
    QFile file(textFile);//文件命名
    if (!file.open(QFile::WriteOnly | QFile::Text))     //检测文件是否打开
    {
          //QMessageBox::information(this, "Error Message", "Please Select a Text File!");
          return;
    }
    QTextStream out(&file);                 //分行写入文件
    out << "测试总数：" + ui->testCountsTextEdit->toPlainText();
    out << "\n成功数量：" + ui->passedCountsTextEdit->toPlainText();
    out << "\n失败数量：" + ui->failTextEdit->toPlainText();
    out << "\n合格率：" + ui->passedRateTextEdit->toPlainText();
}

void Widget::dispTips(uchar *data)
{
    //返回信息提示
    uint8_t id;//目标板编号
    if(data[5] == 0x04){
        id = data[6];
        switch (id) {
        case 1:
            switch (data[4]) {
            case 0:
                //发送成功，可做超时判断依据
                break;
            case 1:
                ui->Num1label->setText("错  误:");
                ui->Num1lineEdit->setText("字库下载错误！");
                break;
            case 2:
                ui->Num1label->setText("错  误:");
                ui->Num1lineEdit->setText("程序下载错误！");
                break;
            case 3:
                ui->Num1label->setText("错  误:");
                ui->Num1lineEdit->setText("连接设备超时！");
                break;
            case 4:
                ui->Num1label->setText("错  误:");
                ui->Num1lineEdit->setText("设备重启后显示异常！");
                break;
            case 5:
                ui->Num1label->setText("错  误:");
                ui->Num1lineEdit->setText("获取列表超时！");
                break;
            case 6:
                ui->Num1label->setText("错  误:");
                ui->Num1lineEdit->setText("设备未启动！");
                break;
            case 7:
                ui->Num1label->setText("错  误:");
                ui->Num1lineEdit->setText("设备编号不对！");
                break;
            default:
                ui->Num1label->setText("错  误:");
                ui->Num1lineEdit->setText("返回一个未知错误！");
                QMessageBox::critical(this,"错  误:","设备返回一个未知错误，请记录并反馈！");
                break;
            }
            if(data[4] != 0){
                ui->Num1lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            break;
        case 2:
            switch (data[4]) {
            case 0:
                //发送成功，可做超时判断依据
                break;
            case 1:
                ui->Num2label->setText("错  误:");
                ui->Num2lineEdit->setText("字库下载错误！");
                break;
            case 2:
                ui->Num2label->setText("错  误:");
                ui->Num2lineEdit->setText("程序下载错误！");
                break;
            case 3:
                ui->Num2label->setText("错  误:");
                ui->Num2lineEdit->setText("连接设备超时！");
                break;
            case 4:
                ui->Num2label->setText("错  误:");
                ui->Num2lineEdit->setText("设备重启后显示异常！");
                break;
            case 5:
                ui->Num2label->setText("错  误:");
                ui->Num2lineEdit->setText("获取列表超时！");
                break;
            case 6:
                ui->Num2label->setText("错  误:");
                ui->Num2lineEdit->setText("设备未启动！");
                break;
            case 7:
                ui->Num2label->setText("错  误:");
                ui->Num2lineEdit->setText("设备编号不对！");
                break;
            default:
                ui->Num2label->setText("错  误:");
                ui->Num2lineEdit->setText("返回一个未知错误！");
                QMessageBox::critical(this,"错  误:","设备返回一个未知错误，请记录并反馈！");
                break;

            }
            if(data[4] != 0){
                ui->Num2lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            break;
        case 3:
            switch (data[4]) {
            case 0:
                //发送成功，可做超时判断依据
                break;
            case 1:
                ui->Num3label->setText("错  误:");
                ui->Num3lineEdit->setText("字库下载错误！");
                break;
            case 2:
                ui->Num3label->setText("错  误:");
                ui->Num3lineEdit->setText("程序下载错误！");
                break;
            case 3:
                ui->Num3label->setText("错  误:");
                ui->Num3lineEdit->setText("连接设备超时！");
                break;
            case 4:
                ui->Num3label->setText("错  误:");
                ui->Num3lineEdit->setText("设备重启后显示异常！");
                break;
            case 5:
                ui->Num3label->setText("错  误:");
                ui->Num3lineEdit->setText("获取列表超时！");
                break;
            case 6:
                ui->Num3label->setText("错  误:");
                ui->Num3lineEdit->setText("设备未启动！");
                break;
            case 7:
                ui->Num3label->setText("错  误:");
                ui->Num3lineEdit->setText("设备编号不对！");
                break;
            default:
                ui->Num3label->setText("错  误:");
                ui->Num3lineEdit->setText("返回一个未知错误！");
                QMessageBox::critical(this,"错  误:","设备返回一个未知错误，请记录并反馈！");
                break;

            }
            if(data[4] != 0){
                ui->Num3lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            break;
        case 4:
            switch (data[4]) {
            case 0:
                //发送成功，可做超时判断依据
                break;
            case 1:
                ui->Num4label->setText("错  误:");
                ui->Num4lineEdit->setText("字库下载错误！");
                break;
            case 2:
                ui->Num4label->setText("错  误:");
                ui->Num4lineEdit->setText("程序下载错误！");
                break;
            case 3:
                ui->Num4label->setText("错  误:");
                ui->Num4lineEdit->setText("连接设备超时！");
                break;
            case 4:
                ui->Num4label->setText("错  误:");
                ui->Num4lineEdit->setText("设备重启后显示异常！");
                break;
            case 5:
                ui->Num4label->setText("错  误:");
                ui->Num4lineEdit->setText("获取列表超时！");
                break;
            case 6:
                ui->Num4label->setText("错  误:");
                ui->Num4lineEdit->setText("设备未启动！");
                break;
            case 7:
                ui->Num4label->setText("错  误:");
                ui->Num4lineEdit->setText("设备编号不对！");
                break;
            default:
                ui->Num4label->setText("错  误:");
                ui->Num4lineEdit->setText("返回一个未知错误！");
                QMessageBox::critical(this,"错  误:","设备返回一个未知错误，请记录并反馈！");
                break;
            }
            if(data[4] != 0){
                ui->Num4lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            break;
        case 5:
            switch (data[4]) {
            case 0:
                //发送成功，可做超时判断依据
                break;
            case 1:
                ui->Num5label->setText("错  误:");
                ui->Num5lineEdit->setText("字库下载错误！");
                break;
            case 2:
                ui->Num5label->setText("错  误:");
                ui->Num5lineEdit->setText("程序下载错误！");
                break;
            case 3:
                ui->Num5label->setText("错  误:");
                ui->Num5lineEdit->setText("连接设备超时！");
                break;
            case 4:
                ui->Num5label->setText("错  误:");
                ui->Num5lineEdit->setText("设备重启后显示异常！");
                break;
            case 5:
                ui->Num5label->setText("错  误:");
                ui->Num5lineEdit->setText("获取列表超时！");
                break;
            case 6:
                ui->Num5label->setText("错  误:");
                ui->Num5lineEdit->setText("设备未启动！");
                break;
            case 7:
                ui->Num5label->setText("错  误:");
                ui->Num5lineEdit->setText("设备编号不对！");
                break;
            default:
                ui->Num5label->setText("错  误:");
                ui->Num5lineEdit->setText("返回一个未知错误！");
                QMessageBox::critical(this,"错  误:","设备返回一个未知错误，请记录并反馈！");
                break;

            }
            if(data[4] != 0){
                ui->Num5lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            break;
        case 6:
            switch (data[4]) {
            case 0:
                //发送成功，可做超时判断依据
                break;
            case 1:
                ui->Num6label->setText("错  误:");
                ui->Num6lineEdit->setText("字库下载错误！");
                break;
            case 2:
                ui->Num6label->setText("错  误:");
                ui->Num6lineEdit->setText("程序下载错误！");
                break;
            case 3:
                ui->Num6label->setText("错  误:");
                ui->Num6lineEdit->setText("连接设备超时！");
                break;
            case 4:
                ui->Num6label->setText("错  误:");
                ui->Num6lineEdit->setText("设备重启后显示异常！");
                break;
            case 5:
                ui->Num6label->setText("错  误:");
                ui->Num6lineEdit->setText("获取列表超时！");
                break;
            case 6:
                ui->Num6label->setText("错  误:");
                ui->Num6lineEdit->setText("设备未启动！");
                break;
            case 7:
                ui->Num6label->setText("错  误:");
                ui->Num6lineEdit->setText("设备编号不对！");
                break;
            default:
                ui->Num6label->setText("错  误:");
                ui->Num6lineEdit->setText("返回一个未知错误！");
                QMessageBox::critical(this,"错  误:","设备返回一个未知错误，请记录并反馈！");
                break;
            }
            if(data[4] != 0){
                ui->Num6lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            break;
        default:
            QMessageBox::critical(this,"错  误:","设备返回一个未知错误，请记录并反馈！");
            break;
        }

    }else {
        QMessageBox::critical(this,"错  误:","返回数据错误->非测试目标数据");
    }

}
void Widget::dispResult(uchar *data)
{
    uint8_t id;//目标板编号
    if(data[4] == 0x04){
        id = data[5];
        switch (data[5]) {
        case 1:
            //data6~9
            ui->Num1lineEdit->setText("测试通过");
            ui->Num1lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            //10：esam
            if(data[10] == 0xA0){
                ui->Esam1lineEdit->setText("测试通过");
                ui->Esam1lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Esam1lineEdit->setText("测试失败");
                ui->Esam1lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //脉冲
            if(data[11] == 0xA0){
                ui->Pulse1lineEdit->setText("测试通过");
                ui->Pulse1lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Pulse1lineEdit->setText("测试失败");
                ui->Pulse1lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //阀门
            if(data[12] == 0xA0){
                ui->Valve1lineEdit->setText("测试通过");
                ui->Valve1lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Valve1lineEdit->setText("测试失败");
                ui->Valve1lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //记录
            if(data[13] == 0xA0){
                ui->Rec1lineEdit->setText("需改程序");
                ui->Rec1lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
//            }else{
//                ui->Rec1lineEdit->setText("测试失败");
//                ui->Rec1lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //读卡
            if(data[14] == 0xA0){
                ui->Rdcd1lineEdit->setText("测试通过");
                ui->Rdcd1lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Rdcd1lineEdit->setText("测试失败");
                ui->Rdcd1lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //信号强度
            if(data[15] == 0xA0){
                ui->Sig1lineEdit->setText("无需测试");
                ui->Sig1lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
//            }else{
//                ui->Sig1lineEdit->setText("测试失败");
//                ui->Sig1lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //磁攻击
            if(data[16] == 0xA0){
                ui->Cgj1lineEdit->setText("无需测试");
                ui->Cgj1lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
//            }else{
//                ui->Cgj1lineEdit->setText("测试失败");
//                ui->Cgj1lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            break;
        case 2:
            ui->Num2lineEdit->setText("测试通过");
            ui->Num2lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            //10：esam
            if(data[10] == 0xA0){
                ui->Esam2lineEdit->setText("测试通过");
                ui->Esam2lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Esam2lineEdit->setText("测试失败");
                ui->Esam2lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //脉冲
            if(data[11] == 0xA0){
                ui->Pulse2lineEdit->setText("测试通过");
                ui->Pulse2lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Pulse2lineEdit->setText("测试失败");
                ui->Pulse2lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //阀门
            if(data[12] == 0xA0){
                ui->Valve2lineEdit->setText("测试通过");
                ui->Valve2lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Valve2lineEdit->setText("测试失败");
                ui->Valve2lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //记录
            if(data[13] == 0xA0){
                ui->Rec2lineEdit->setText("需改程序");
                ui->Rec2lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
//            }else{
//                ui->Rec2lineEdit->setText("测试失败");
//                ui->Rec2lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //读卡
            if(data[14] == 0xA0){
                ui->Rdcd2lineEdit->setText("测试通过");
                ui->Rdcd2lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Rdcd2lineEdit->setText("测试失败");
                ui->Rdcd2lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //信号强度
            if(data[15] == 0xA0){
                ui->Sig2lineEdit->setText("无需测试");
                ui->Sig2lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
//            }else{
//                ui->Sig1lineEdit->setText("测试失败");
//                ui->Sig1lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //磁攻击
            if(data[16] == 0xA0){
                ui->Cgj2lineEdit->setText("无需测试");
                ui->Cgj2lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
//            }else{
//                ui->Cgj1lineEdit->setText("测试失败");
//                ui->Cgj1lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            break;
        case 3:
            ui->Num3lineEdit->setText("测试通过");
            ui->Num3lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            //10：esam
            if(data[10] == 0xA0){
                ui->Esam3lineEdit->setText("测试通过");
                ui->Esam3lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Esam3lineEdit->setText("测试失败");
                ui->Esam3lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //脉冲
            if(data[11] == 0xA0){
                ui->Pulse3lineEdit->setText("测试通过");
                ui->Pulse3lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Pulse3lineEdit->setText("测试失败");
                ui->Pulse3lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //阀门
            if(data[12] == 0xA0){
                ui->Valve3lineEdit->setText("测试通过");
                ui->Valve3lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Valve3lineEdit->setText("测试失败");
                ui->Valve3lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //记录
            if(data[13] == 0xA0){
                ui->Rec3lineEdit->setText("需改程序");
                ui->Rec3lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
//            }else{
//                ui->Rec3lineEdit->setText("测试失败");
//                ui->Rec3lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //读卡
            if(data[14] == 0x01){
                ui->Rdcd3lineEdit->setText("测试通过");
                ui->Rdcd3lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Rdcd3lineEdit->setText("测试失败");
                ui->Rdcd3lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //信号强度
            if(data[15] == 0xA0){
                ui->Sig3lineEdit->setText("无需测试");
                ui->Sig3lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
//            }else{
//                ui->Sig1lineEdit->setText("测试失败");
//                ui->Sig1lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //磁攻击
            if(data[16] == 0xA0){
                ui->Cgj3lineEdit->setText("无需测试");
                ui->Cgj3lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
//            }else{
//                ui->Cgj1lineEdit->setText("测试失败");
//                ui->Cgj1lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            break;
        case 4:
            ui->Num4lineEdit->setText("测试通过");
            ui->Num4lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            //10：esam
            if(data[10] == 0xA0){
                ui->Esam4lineEdit->setText("测试通过");
                ui->Esam4lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Esam4lineEdit->setText("测试失败");
                ui->Esam4lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //脉冲
            if(data[11] == 0xA0){
                ui->Pulse4lineEdit->setText("测试通过");
                ui->Pulse4lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Pulse4lineEdit->setText("测试失败");
                ui->Pulse4lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //阀门
            if(data[12] == 0xA0){
                ui->Valve4lineEdit->setText("测试通过");
                ui->Valve4lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Valve4lineEdit->setText("测试失败");
                ui->Valve4lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //记录
            if(data[13] == 0xA0){
                ui->Rec4lineEdit->setText("需改程序");
                ui->Rec4lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
//            }else{
//                ui->Rec4lineEdit->setText("测试失败");
//                ui->Rec4lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //读卡
            if(data[14] == 0xA0){
                ui->Rdcd4lineEdit->setText("测试通过");
                ui->Rdcd4lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Rdcd4lineEdit->setText("测试失败");
                ui->Rdcd4lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //信号强度
            if(data[15] == 0xA0){
                ui->Sig4lineEdit->setText("无需测试");
                ui->Sig4lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
//            }else{
//                ui->Sig1lineEdit->setText("测试失败");
//                ui->Sig1lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //磁攻击
            if(data[16] == 0xA0){
                ui->Cgj4lineEdit->setText("无需测试");
                ui->Cgj4lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
//            }else{
//                ui->Cgj1lineEdit->setText("测试失败");
//                ui->Cgj1lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            break;
        case 5:
            ui->Num5lineEdit->setText("测试通过");
            ui->Num5lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            //10：esam
            if(data[10] == 0xA0){
                ui->Esam5lineEdit->setText("测试通过");
                ui->Esam5lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Esam5lineEdit->setText("测试失败");
                ui->Esam5lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //脉冲
            if(data[11] == 0xA0){
                ui->Pulse5lineEdit->setText("测试通过");
                ui->Pulse5lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Pulse5lineEdit->setText("测试失败");
                ui->Pulse5lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //阀门
            if(data[12] == 0xA0){
                ui->Valve5lineEdit->setText("测试通过");
                ui->Valve5lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Valve5lineEdit->setText("测试失败");
                ui->Valve5lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //记录
            if(data[13] == 0xA0){
                ui->Rec5lineEdit->setText("需改程序");
                ui->Rec5lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
//            }else{
//                ui->Rec5lineEdit->setText("测试失败");
//                ui->Rec5lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //读卡
            if(data[14] == 0xA0){
                ui->Rdcd5lineEdit->setText("测试通过");
                ui->Rdcd5lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Rdcd5lineEdit->setText("测试失败");
                ui->Rdcd5lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //信号强度
            if(data[15] == 0xA0){
                ui->Sig5lineEdit->setText("无需测试");
                ui->Sig5lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
//            }else{
//                ui->Sig1lineEdit->setText("测试失败");
//                ui->Sig1lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //磁攻击
            if(data[16] == 0xA0){
                ui->Cgj5lineEdit->setText("无需测试");
                ui->Cgj5lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
//            }else{
//                ui->Cgj1lineEdit->setText("测试失败");
//                ui->Cgj1lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            break;
        case 6:
            ui->Num6lineEdit->setText("测试通过");
            ui->Num6lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            //10：esam
            if(data[10] == 0xA0){
                ui->Esam6lineEdit->setText("测试通过");
                ui->Esam6lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Esam6lineEdit->setText("测试失败");
                ui->Esam6lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //脉冲
            if(data[11] == 0xA0){
                ui->Pulse6lineEdit->setText("测试通过");
                ui->Pulse6lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Pulse6lineEdit->setText("测试失败");
                ui->Pulse6lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //阀门
            if(data[12] == 0xA0){
                ui->Valve6lineEdit->setText("测试通过");
                ui->Valve6lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Valve6lineEdit->setText("测试失败");
                ui->Valve6lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //记录
            if(data[13] == 0xA0){
                ui->Rec6lineEdit->setText("需改程序");
                ui->Rec6lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
//            }else{
//                ui->Rec6lineEdit->setText("测试失败");
//                ui->Rec6lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //读卡
            if(data[14] == 0xA0){
                ui->Rdcd6lineEdit->setText("测试通过");
                ui->Rdcd6lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
            }else{
                ui->Rdcd6lineEdit->setText("测试失败");
                ui->Rdcd6lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //信号强度
            if(data[15] == 0xA0){
                ui->Sig6lineEdit->setText("无需测试");
                ui->Sig6lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
//            }else{
//                ui->Sig1lineEdit->setText("测试失败");
//                ui->Sig1lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            //磁攻击
            if(data[16] == 0xA0){
                ui->Cgj6lineEdit->setText("无需测试");
                ui->Cgj6lineEdit->setStyleSheet("background-color: rgb(85, 255, 0);");
//            }else{
//                ui->Cgj1lineEdit->setText("测试失败");
//                ui->Cgj1lineEdit->setStyleSheet("background-color: rgb(255, 0, 0);");
            }
            break;
        default:
            break;

        }
    }else {
        QMessageBox::critical(this,"错误","返回数据错误->非测试目标数据");
}
}

void Widget::cleanResult()
{
    ui->Num1lineEdit->clear();
    ui->Num1label->setText("编  号:");
    ui->Num1lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Num2lineEdit->clear();
    ui->Num2label->setText("编  号:");
    ui->Num2lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Num3lineEdit->clear();
    ui->Num3label->setText("编  号:");
    ui->Num3lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Num4lineEdit->clear();
    ui->Num4label->setText("编  号:");
    ui->Num4lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Num5lineEdit->clear();
    ui->Num5label->setText("编  号:");
    ui->Num5lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Num6lineEdit->clear();
    ui->Num6label->setText("编  号:");
    ui->Num6lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");

    ui->Esam1lineEdit->clear();
    ui->Esam1lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Esam2lineEdit->clear();
    ui->Esam2lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Esam3lineEdit->clear();
    ui->Esam3lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Esam4lineEdit->clear();
    ui->Esam4lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Esam5lineEdit->clear();
    ui->Esam5lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Esam6lineEdit->clear();
    ui->Esam6lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");

    ui->Pulse1lineEdit->clear();
    ui->Pulse1lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Pulse2lineEdit->clear();
    ui->Pulse2lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Pulse3lineEdit->clear();
    ui->Pulse3lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Pulse4lineEdit->clear();
    ui->Pulse4lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Pulse5lineEdit->clear();
    ui->Pulse5lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Pulse6lineEdit->clear();
    ui->Pulse6lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");

    ui->Valve1lineEdit->clear();
    ui->Valve1lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Valve2lineEdit->clear();
    ui->Valve2lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Valve3lineEdit->clear();
    ui->Valve3lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Valve4lineEdit->clear();
    ui->Valve4lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Valve5lineEdit->clear();
    ui->Valve5lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Valve6lineEdit->clear();
    ui->Valve6lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");

    ui->Rec1lineEdit->clear();
    ui->Rec1lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Rec2lineEdit->clear();
    ui->Rec2lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Rec3lineEdit->clear();
    ui->Rec3lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Rec4lineEdit->clear();
    ui->Rec4lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Rec5lineEdit->clear();
    ui->Rec5lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Rec6lineEdit->clear();
    ui->Rec6lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");

    ui->Rdcd1lineEdit->clear();
    ui->Rdcd1lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Rdcd2lineEdit->clear();
    ui->Rdcd2lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Rdcd3lineEdit->clear();
    ui->Rdcd3lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Rdcd4lineEdit->clear();
    ui->Rdcd4lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Rdcd5lineEdit->clear();
    ui->Rdcd5lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Rdcd6lineEdit->clear();
    ui->Rdcd6lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");

    ui->Sig1lineEdit->clear();
    ui->Sig1lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Sig2lineEdit->clear();
    ui->Sig2lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Sig3lineEdit->clear();
    ui->Sig3lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Sig4lineEdit->clear();
    ui->Sig4lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Sig5lineEdit->clear();
    ui->Sig5lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Sig6lineEdit->clear();
    ui->Sig6lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");

    ui->Cgj1lineEdit->clear();
    ui->Cgj1lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Cgj2lineEdit->clear();
    ui->Cgj2lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Cgj3lineEdit->clear();
    ui->Cgj3lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Cgj4lineEdit->clear();
    ui->Cgj4lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Cgj5lineEdit->clear();
    ui->Cgj5lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
    ui->Cgj6lineEdit->clear();
    ui->Cgj6lineEdit->setStyleSheet("background-color: rgb(255, 255, 255);");
}


